package com.itheima.dao;

import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CheckgroupDao {

    //增删改查工程师
    @Select("select * from t_checkgroup where code like '%${queryString}%' or name like '%${queryString}%' or helpCode like '%${queryString}%'")
    List<CheckGroup> findPage(@Param("queryString") String queryString);

    void add(CheckGroup checkGroup);

    @Insert("insert into t_checkgroup_checkitem values (#{checkGroupId},#{checkitemId})")
    void add2Mid(@Param("checkGroupId") Integer checkGroupId,@Param("checkitemId") int checkitemId);

    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(int id);

    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    List<Integer> findCheckItemIdsByCheckGroupId(int id);

    @Update("update t_checkgroup set code = #{code},name = #{name},helpCode = #{helpCode},sex = #{sex},remark = #{remark},attention = #{attention} where id = #{id}")
    void edit(CheckGroup checkGroup);

    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    void deleteMid(Integer checkGroupId);

    @Delete("delete from t_setmeal_checkgroup where checkgroup_id = #{id}")
    void deleteSetmealCheckgroupMid(int id);

    @Delete("delete from t_checkgroup where id = #{id}")
    void deleteCheckgroupById(int id);

    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();

    @Select("select * from t_checkgroup where id in (select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id})")
    List<CheckGroup> findCheckGroupsBySetmealId(int id);
}
